package com.hc.comm.exception;


import java.util.HashMap;
import java.util.Map;

/**
 * 操作异常类，一些不合法的操作都可以抛出该异常，页面将显示异常信息
 * 
 * @author 
 */
public class OperateException extends RuntimeException {

	/**
	 * 状态码
	 */
	private String resultState;

	/**
	 * 回调页面
	 */
	private String returnUrl;

	/**
	 * 扩展参数
	 */
	private Map<Object, Object> extendMap;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public OperateException(){}
	public OperateException(String message) {
		super(message);
	}

	public OperateException(String resultState, String message) {
		super(message);
		this.resultState = resultState;
	}

	public OperateException(String returnUrl, String resultState, String message) {
		super(message);
		this.resultState = resultState;
		this.returnUrl = returnUrl;
	}

	public String getResultState() {
		return resultState;
	}

	public void setResultState(String resultState) {
		this.resultState = resultState;
	}

	public Map<Object, Object> getExtendMap() {
		return extendMap;
	}

	public void setExtendMap(Map<Object, Object> extendMap) {
		this.extendMap = extendMap;
	}

	public String getReturnUrl() {
		return returnUrl;
	}

	public void setReturnUrl(String returnUrl) {
		this.returnUrl = returnUrl;
	}

	public void put(Object key, Object obj) {
		if (this.extendMap == null) {
			this.extendMap = new HashMap<Object, Object>();
		}
		this.extendMap.put(key, obj);
	}

	@SuppressWarnings("unchecked")
	public <T> T get(Object key) {
		return (T) this.extendMap.get(key);
	}

}
